<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>数组排序</title>
    <script>
      //数组排序
      function ArrSort(arr) {
        /*pre - next < 0, pre排在next前
         *pre - next > 0, pre排在next后
         *pre = next , 保持
         */
        var newArr = arr.sort((pre, next) => pre - next);
        console.log("排序后的数组：", newArr);
      }
      ArrSort([3, 4, 1, 2, 6, 5]); //排序后的数组： (6) [1, 2, 3, 4, 5, 6]
    </script>
  </head>
  <body></body>
</html>
